//
//  OPHNetwork.h
//  Pods
//
//  Created by lingen on 16/3/24.
//
//

#import <Foundation/Foundation.h>
#import "OPHRequest.h"

@class OPHResponse;
@class OPHUploadRequest;
@class OPHDownloadRequest;
@class AFURLSessionManager;

/**
 *  同步请求
 */
@interface OPHNetwork : NSObject

+(instancetype)sharedInstance;

+(instancetype)createInstanceWithQueue:(int)queueCount;

@property (nonatomic, strong, readonly) AFURLSessionManager *sessionManager;

/**
 *  发出一个上传文件的请求
 *
 *  @param reqeust        OPHUploadRequest请求ß
 *  @param progressBlock  进度
 *  @param comepleteBlock 回调
 */
-(void)uploadRequest:(OPHUploadRequest*)reqeust progress:(void(^)(float progress))progressBlock comeplete:(void(^)(OPHResponse* response))comepleteBlock;


/**
 *  发出一个下载请求
 *
 *  @param request        请求
 *  @param progressBlock  progress回调
 *  @param comepleteBlock 完成回调
 */
-(void)downloadRequest:(OPHDownloadRequest*)request progress:(void(^)(float progress))progressBlock comeplete:(void(^)(NSString* filePath))comepleteBlock;

-(BOOL)isDownloading:(NSString*)donwloadId;

-(BOOL)isUploading:(NSString*)uploadId;

-(BOOL)cancelAllUnFinished;

-(BOOL)cancelAllUploads;

-(BOOL)cancelAllDownloads;
/**
 *  取消一个上传行为
 *
 *  @param uploadId 上传
 *
 *  @return 是否取消成功
 */
-(BOOL)cancelUploadRequest:(NSString*)uploadId;

/*
 * 暂停一个上传行为
 */
-(BOOL)pauseUplaodRequest:(NSString*)uploadId;

/*
 * 重启一个上传行为
 */
-(BOOL)resumeUploadRequest:(NSString*)uploadId;



/**
 *  取消一个下载行为
 *
 *  @param downloadId download ID
 *
 *  @return 返回是否取消成功
 */
-(BOOL)cancelDownloadRequest:(NSString*)downloadId;

/*
 *  暂停一个下载行为
 */
-(BOOL)pauseDownloadRequest:(NSString*)downloadId;

/*
 *  重启一个下载行为
 */
-(BOOL)resumeDownloadRequest:(NSString*)downlaodId;


-(OPHResponse*)syncRequest:(OPHRequest*)request;

-(void)setDefaultHeader:(NSString*)value forKey:(NSString*)key;

-(BOOL)hasUnCompleteDownloadOrUpload;



@end
